////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRayUIFrontEnd_MainMenu extends UTUIFrontEnd_MainMenu;

const BailterRay_MAINMENU_OPTION_INSTANTACTION = 0;
const BailterRay_MAINMENU_OPTION_SETTINGS = 1;
const BailterRay_MAINMENU_OPTION_EXIT = 2;

var int GameDifficulty;

function OnSelectItem(int PlayerIndex=0)
{
    switch(MenuList.GetCurrentItem())
    {
        case BailterRay_MAINMENU_OPTION_INSTANTACTION:
            //OpenSceneByName(InstantActionScene);
            //MyOnStartGame_Confirm();
            OnMenu_ChooseMode();
            break;

        case BailterRay_MAINMENU_OPTION_SETTINGS:
            OpenSceneByName(SettingsScene);
            break;

        case BailterRay_MAINMENU_OPTION_EXIT:
            OnMenu_ExitGame();
            break;
    }
}

function MyOnStartGame_Confirm()
{
	//local Settings GameSettings;
	//local string URL;
	local string GameExec;
	//local string Mutators;
	//local int OutValue;

	// Play the startgame sound
	PlayUISound('StartGame');

	// Start the game.
	GameExec = "open BR-BailterRayPlanet_01?game=BailterRay.BailterRay?GameDifficulty="$GameDifficulty$"?MaxPlayers=1?MinNetPlayers=0?NumPublicConnections=16?NumPrivateConnections=0?NumOpenPublicConnections=0?NumOpenPrivateConnections=0?bShouldAdvertise=True?bIsLanMatch=false?bUsesStats=True?bAllowJoinInProgress=True?bAllowInvites=True?bUsesPresence=True?bAllowJoinViaPresence=True?bUsesArbitration=false?bIsDedicated=false?bIsListPlay=false?OwningPlayerName=?GameMode=0?Difficulty=6?PureServer=1?LockedServer=0?Campaign=0?ForceRespawn=0?GoalScore=1?TimeLimit=0?ServerDescription=?NumPlay=1?name=AstroExplorer";
	//GameExec = "open " $ MapTab.GetFirstMap() $ "?game=" $ GameMode $ URL;
	LogInternal("UTUIFrontEnd: Starting Game..." $ GameExec);
	ConsoleCommand(GameExec);

}

/** Setup the scene's buttonbar. */
function SetupButtonBar()
{
	ButtonBar.Clear();

}

function OnMenu_ChooseMode()
{
	local array<string> MessageBoxOptions;

	MessageBoxReference = GetMessageBoxScene();

	if(MessageBoxReference != none)
	{
		MessageBoxOptions.AddItem("Easy");
		MessageBoxOptions.AddItem("Hard");

		MessageBoxReference.SetPotentialOptions(MessageBoxOptions);
		MessageBoxReference.Display("Choose the Game Difficulty", "Bailter Ray", OnMenu_Mode_Confirm, 1);
	}

	MessageBoxReference = None;
}

function OnMenu_Mode_Confirm(UTUIScene_MessageBox MessageBox, int SelectedItem, int PlayerIndex)
{
	if( SelectedItem == 0 )
	{
        GameDifficulty = 0;
	}
	if( SelectedItem == 1 )
	{
        GameDifficulty = 1;
	}
	MyOnStartGame_Confirm();
}


/** Exit game option selected. */
function OnMenu_ExitGame()
{
   ConsoleCommand("quit");
}

defaultproperties
{
   LoginScreenScene=""
   CDKeyScene=""
}